import {baseEffects, baseReducers, baseState} from "../../../../models/baseModel";
import moment from "moment";
import * as request from "../../../../services/CommonHttpService";
import $$ from 'utils';

export default {
  namespace: 'dataList',

  state: {
    ...baseState,
    deviceInfo: {},
    chartData: [],
    uploadStatistics: [],
  },

  reducers: {
    ...baseReducers
  },

  effects: {

    ...baseEffects,

    // moment().format('YYYY-MM-DD HH:mm:ss'),

    * getPageInfo({payload}, {call, put}) {

      const p = {
        ...payload,
        baseUrl: "/data",
        process: (records) => {
          return records.map(record => {
            return {
              ...record,
              result: Math.floor(record.result * 100) / 100,
              time: moment(record.time).format('YYYY-MM-DD HH:mm:ss'),
            };
          });
        }
      }

      yield put({
        type: 'baseGetPageInfo',
        payload: p
      });
    },

  }

}

function getBaseUrl() {
  return "/device";
}

